angular.module('mamApp').controller('specialTagsChannelController', ['$scope', '$state', '$uibModal','ImsDialog','TagsManager','$filter',
    function ($scope, $state, $uibModal, ImsDialog, TagsManager, $filter) {

    $scope.search = {
        pageNo: $state.params.pageNo || 1,
        pageSize: $state.params.pageSize || 10
    };

    $scope.paginationConf = {
        currentPage: $state.params.pageNo || 1,
        itemsPerPage: $state.params.pageSize || 10,
        pagesLength: 9,
        search: 0,
        onChange: function () {
            $scope.search.pageNo = this.currentPage;
            $scope.search.pageSize = this.itemsPerPage;
            $state.go($state.current.name, $scope.search)
        }
    };

    //专用标签列表--频道
    $scope.noPermission=false;
    TagsManager.specialTagsChannelList([$scope.search.pageNo, $scope.search.pageSize]).then(function (result) {

        if(result.data.c=="n"){
            $scope.noPermission=true;
        }else{
            $scope.noPermission=false;
            $scope.specialTagsChannelList = result.data.pageList;
            $scope.paginationConf.totalItems = result.data.total;
        }

    });

    //初始化全选值为false
    $scope.checkData={allChecked:false};
    //全选
    $scope.selectAllChange=function (checked) {
        $scope.specialTagsChannelList.forEach(function (item) {
            item.checked=checked;
        })
    };
    //选择一个
    $scope.selectOneChange=function (checked) {
        if(!checked){
            $scope.checkData.allChecked=false;
        }else {
            ($filter('filter')($scope.specialTagsChannelList,{checked:true}).length)==$scope.specialTagsChannelList.length?$scope.checkData.allChecked=true:$scope.checkData.allChecked=false;
        }
    };
        $scope.keyup=function (e,keyword) {

            if(e.key=="Enter"){
                alert(123);
                /*$scope.search.pageNo=1;
                $scope.search.keyword = keyword;
                $scope.search.reviewStatus = $scope.search.reviewStatus == "null" ? null : $scope.search.reviewStatus;
                $state.go($state.current.name, $scope.search);*/
            }
        }



    }]);

